package com.src.isec.domain.interactor;

import com.src.isec.domain.entity.UserEntity;
import com.src.isec.domain.repository.IUserRepository;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Singleton;

import io.reactivex.Observable;

/**
 * @author liujiancheng
 * @name IsecLive
 * @class name：com.src.isec.domain.interactor
 * @class describe
 * @time 2018/3/21 16:36
 * @change
 * @chang time
 * @class describe
 */
@Singleton
public class UsersUesCase extends UseCase<List<UserEntity>, UsersUesCase.Params> {


    private final IUserRepository mIUserRepository;

    @Inject
    public UsersUesCase(IUserRepository iUserRepository) {

        mIUserRepository = iUserRepository;
    }

    @Override
    protected Observable<List<UserEntity>> buildUseCaseObservable(Params params) {
        return mIUserRepository.getUserList(params.lastIdQueried, params.perPage);
    }

    public static final class Params {

        private final int lastIdQueried;
        private final int perPage;

        private Params(int lastIdQueried, int perPage) {
            this.lastIdQueried = lastIdQueried;
            this.perPage = perPage;
        }

        public static Params get(int lastIdQueried, int perPage) {
            return new Params(lastIdQueried, perPage);
        }
    }
}
